<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateStatDailyCoinTable extends Migration
{
    protected $connection = 'stat';
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('stat_daily_coin', function (Blueprint $table) {
            $table->increments('id');
            $table->date('dt')->comment('统计日期');
            $table->double('total_consume', 10, 1)->default(0.0)->comment('总消费金币');
            $table->double('video_consume', 10, 1)->default(0.0)->comment('视频消费金币');
            $table->double('voice_consume', 10, 1)->default(0.0)->comment('语音消费金币');
            $table->double('gift_consume', 10, 1)->default(0.0)->comment('礼物消费金币');
            $table->double('msg_consume', 10, 1)->default(0.0)->comment('私信消费金币');
            $table->double('other_consume', 10, 1)->default(0.0)->comment('其他消费金币');
            $table->char('channel', 10)->default('')->comment('注册渠道');
            $table->timestamps();
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->index('dt', 'dt');
            $table->index('channel', 'channel');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('stat_daily_coin');
    }
}
